/*
  ! 前途似海，来日方长。
  ! Created: 2024/12/04 09:56:28
*/
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
// #define int long long
#define mp(x, y) make_pair(x, y)
#define eb(...) emplace_back(__VA_ARGS__)
#define fro(i, x, y) for (int i = (x); i <= (y); i++)
#define pre(i, x, y) for (int i = (x); i >= (y); i--)
inline void JYFILE19();

using i64 = long long;
using pii = pair<int, int>;

bool ST;
const int N = 1e6 + 10;
const int mod = 998244353;

int n, m;
i64 a[N];
i64 b[N];
i64 vl[N], t1[N];
int sz[N], t2[N];
i64 ls, rs, ns, cr, nw;
set<i64> q;

namespace IO {
char buf[1<<21], s[1<<21], *p1, *p2;
#define gc() (p1==p2&&(p2=(p1=buf)+cin.rdbuf()->sgetn(buf,1<<21),p1==p2)?EOF:*p1++)
template<typename T> inline void read(T &x) {
  x = 0; char z;
  while(!isdigit(z = gc()));
  while(isdigit(z)) x = x * 10 + (z ^ 48), z = gc();
}
template<typename T> inline void put(T a) {
  int tp = 0;
  if(!a) cout.rdbuf()->sputc('0');
  else {
    while(a) s[++tp] = a % 10 + 48 , a /= 10;
    while(tp) cout.rdbuf()->sputc(s[tp--]);
  }
  cout.rdbuf()->sputc('\n');
}
} using IO::put; using IO::read;

inline void upd(int p, int l, int r, int k, i64 v1, int v2) {
  vl[p] += v1;
  sz[p] += v2;
  if (l != r) {
    int mid = (l + r) >> 1;
    if (mid >= k) upd(mid<<1, l, mid, k, v1, v2);
    if (mid <  k) upd(mid<<1|1, mid + 1, r, k, v1, v2);
  }
}
inline int lb(int x) {
  return x & (-x);
}
inline void upd(int k, i64 v1, int v2) {
  while (k <= m) t1[k] += v1, t2[k] += v2, k += lb(k);
}
inline i64 ask(int k) {
  int cr = 0, x = 0;
  i64 vl = 0;
  pre(i, 18, 0) {
    if ((x | (1 << i)) > m) continue;
    if (cr + t2[x | (1 << i)] <= k) {
      x |= (1 << i);
      vl += t1[x];
      cr += t2[x];
    }
  }
  return vl;
}
inline void solve(int p, int l, int r) {
  if (!sz[p]) return;
  if (cr + vl[p] <= rs) {
    cr += vl[p];
    nw += sz[p];
    rs = ask(nw);
  } else if (l == r) {
    if (ls <= rs) ns += rs - ls;
    cr += vl[p];
    nw += sz[p];
    ls = cr;
    rs = ask(nw);
  } else {
    int mid = (l + r) >> 1;
    solve(mid<<1, l, mid);
    solve(mid<<1|1, mid + 1, r);
  }
}

signed main() {
  JYFILE19();
  read(n);
  fro(i, 1, n) read(a[i]);
  fro(i, 1, n) b[i] = a[i];
  sort(b + 1, b + n + 1);
  m = unique(b + 1, b + n + 1) - b - 1;
  fro(i, 1, n) a[i] = lower_bound(b + 1, b + m + 1, a[i]) - b;
  fro(i, 1, n) {
    if (q.count(a[i])) {
      q.erase(a[i]);
      upd(m - a[i] + 1, -b[a[i]], -1);
      upd(1, 1, m, a[i], -b[a[i]], -1);
    } else {
      q.insert(a[i]);
      upd(m - a[i] + 1,  b[a[i]],  1);
      upd(1, 1, m, a[i],  b[a[i]],  1);
    }
    ns = 0, ls = 1, rs = 0, cr = 0, nw = 0;
    solve(1, 1, m);
    put(ns);
  }
  return 0;
}

bool ED;
inline void JYFILE19() {
  freopen("kte.in", "r", stdin);
  freopen("kte.out", "w", stdout);
  srand(random_device{}());
  ios::sync_with_stdio(0), cin.tie(0);
  double MIB = fabs((&ED - &ST) / 1048576.), LIM = 512;
  cerr << "MEMORY: " << MIB << endl, assert(MIB <= LIM);
}